File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ """Tests for the addressvalidation module."""
2
+
3
+ #import responses
4
+
5
+ import os
6
+ import sys
7
+ import unittest
8
+ import json
9
+ from os import path
10
+
11
+ #Append source directory of the class to be tested
12
+ sys .path .append (os .path .join (os .path .dirname (sys .path [0 ]),'src' ))
13
+ from av_result_parser import av_result_parser_class
14
+
15
+ NYC_GOOGLE_OFFICE_RESPONSE = 'google_ny_response_test_data.json'
16
+
17
+ # Opening JSON file
18
+ class Testing (unittest .TestCase ):
19
+
20
+ def parse_response ():
21
+ with open (os .path .join (sys .path [0 ],NYC_GOOGLE_OFFICE_RESPONSE )) as json_file :
22
+ av_response_data = json .load (json_file )
23
+
24
+ # Print the type of data variable
25
+ print ("Type:" , type (av_response_data ))
26
+ av_result_parser_load = av_result_parser_class ()
27
+
28
+ parsed_response = av_result_parser_load .parse_av_response (av_response_data )
29
+ print ('The final response after parsing from the test class is::' )
30
+ print (parsed_response ['output_place_ID' ])
31
+ return parsed_response
32
+
33
+ def test_check (self ):
34
+ parsed_response = Testing .parse_response ()
35
+ #These are the hard coded values we are testing against
36
+ expected_place_ID = 'ChIJz1X15L5ZwokR3HHMKxQ7Gtk'
37
+ expected_locality = 'CONFIRMED|inferred'
38
+ #Checking if place_id and locality string matches exactly
39
+ self .assertEqual (parsed_response ['output_place_ID' ], expected_place_ID )
40
+ self .assertEqual (parsed_response ['output_address_components' ]['locality' ], expected_locality )
41
+
42
+
43
+ if __name__ == '__main__' :
44
+ unittest .main ()
You can’t perform that action at this time.
0 commit comments