Esempio n. 1
0
    def test__get_customers_ok(self):
        expected = [
            {"latitude": "0", "user_id": 1, "name": "a", "longitude": "0", "coordinates": (0, 0,)},
            {"latitude": "0", "user_id": 2, "name": "b", "longitude": "0", "coordinates": (0, 0,)},
            {"latitude": "0", "user_id": 3, "name": "c", "longitude": "0", "coordinates": (0, 0,)}
        ]
        inviter = Inviter()
        customer_test = ['{"latitude": "0", "user_id": 2, "name": "b", "longitude": "0"}',
                         '{"latitude": "0", "user_id": 3, "name": "c", "longitude": "0"}',
                         '{"latitude": "0", "user_id": 1, "name": "a", "longitude": "0"}']
        with tempfile.TemporaryDirectory() as temp_dir:
            f_path = os.path.join(temp_dir, 'customers.txt')
            with open(f_path, 'w') as f:
                f.write('\n'.join(customer_test))

            actual = inviter._get_customers(f_path)
            self.assertEqual(actual, expected)
Esempio n. 2
0
 def test__get_customers_bad_file(self):
     inviter = Inviter()
     with tempfile.TemporaryDirectory() as temp_dir:
         f_path = os.path.join(temp_dir, 'customers.txt')
         with self.assertRaises(IOError):
             inviter._get_customers(f_path)