コード例 #1
0
    def setUpClass(cls):
        super(ParcelDomainTestCase, cls).setUpClass()

        cls.base_test_case = {
            'parcel_type': 'medium_box',
            'storage': '5782c996-d0d0-4e4f-895e-e4a98f26c65f',
            'date': ['2019-04-22', '2019-04-10']
        }

        cls.test_parcel = {
            "id": "720745e2-cee6-4338-8399-72b6affb71a6",
            "description": "Food",
            "type_id": "ac13d5ee-61ba-4945-b5e8-a84d8da5a885",
            "weight": 17.3,
            "cost": 381.6,
            "supply_id": "7542e12a-c30b-4e68-9b22-42dbc477cb5a"
        }
        cls.new_parcel = {
            "id": "720745e2-cee6-4338-8399-72b6affb71a6",
            "description": "Food",
            "type_id": "ac13d5ee-61ba-4945-b5e8-a84d8da5a885",
            "weight": 20,
            "cost": 381.6,
            "supply_id": "dcf19a78-b01f-4251-924f-3403df3afdaf"
        }
        cls.good_id = '720745e2-cee6-4338-8399-72b6affb71a6'
        cls.bad_id = '49732169'
        cls.id_not_exist = '42732169-9b7b-4f09-aa1b-7fecb350ab14'
        cls.data = JsonLoader(get_abs_path('parcel.json'))

        cls.ctx = Context(prec=5)
        cls.types = [
            uuid.UUID, str, uuid.UUID, cls.ctx.create_decimal_from_float,
            cls.ctx.create_decimal_from_float, uuid.UUID
        ]

        cls.my_loop = asyncio.get_event_loop()
        cls.my_loop.run_until_complete(
            load_json_data(
                get_dict_gen([
                    get_abs_path(f) for f in [
                        'parceltype.json', 'clients.json', 'storage.json',
                        'supply.json'
                    ]
                ])))
コード例 #2
0
    def setUpClass(cls):
        super(StorageDomainTestCase, cls).setUpClass()

        cls.test_storage = {
            "id": "0148bc1a-90c7-451b-aecc-7081e0f4b60a",
            "address": "197D Klochkovska str.",
            "max_weight": 1000,
            "max_capacity": 30000
        }
        cls.new_storage = {
            "id": "0148bc1a-90c7-451b-aecc-7081e0f4b60a",
            "address": "222 Valentynivska str., apt. 39",
            "max_weight": 100,
            "max_capacity": 20000
        }
        cls.good_id = '0148bc1a-90c7-451b-aecc-7081e0f4b60a'
        cls.bad_id = '49732169'
        cls.id_not_exist = '42732169-9b7b-4f09-aa1b-7fecb350ab14'
        cls.data = JsonLoader(get_abs_path('storage.json'))
コード例 #3
0
    def setUpClass(cls):
        super(ClientDomainTestCase, cls).setUpClass()

        cls.client = [{
            "id": "dcf19a78-b01f-4251-924f-3403df3afdaa",
            "name": "John",
            "email": "*****@*****.**",
            "age": 18,
            "address": "3073 Derek Drive"
        }]
        cls.new_client = [{
            "id": "dcf19a78-b01f-4251-924f-3403df3afdaa",
            "name": "John Galt",
            "email": "*****@*****.**",
            "age": 38,
            "address": "3073 Derek Drive avenue"
        }]
        cls.good_id = 'dcf19a78-b01f-4251-924f-3403df3afdaa'
        cls.bad_id = '49732169'
        cls.id_not_exist = '42732169-9b7b-4f09-aa1b-7fecb350ab14'
        cls.data = JsonLoader(get_abs_path('clients.json'))
コード例 #4
0
def get_dict_gen(files):
    return {get_tab_name(f): JsonLoader(f).loaded_json for f in files}
コード例 #5
0
 def test_load_json_return_gen(self):
     test_load = JsonLoader(self.correct_path).loaded_json
     self.assertIsInstance(test_load, GeneratorType)
コード例 #6
0
 def test_raise_stopiteration_empty_json(self):
     with self.assertRaises(StopIteration):
         test_json = JsonLoader(self.correct_path).loaded_json
         next(test_json)
コード例 #7
0
 def test_assert_json_not_exists(self):
     wrong_file = "./tests/fixtures/aaaa.json"
     error_msg = "File with name {} doesn't exist".format(wrong_file)
     with self.assertRaises(FileNotFoundError) as err:
         JsonLoader.json_exists(wrong_file)
     self.assertEqual(str(err.exception), error_msg)
コード例 #8
0
 def test_json_exists_true(self):
     self.assertTrue(JsonLoader.json_exists(self.correct_path))
コード例 #9
0
 def test_init_error_raise(self):
     with self.assertRaises(TypeError):
         JsonLoader()