Exemplo n.º 1
0
 def test_init_no_args(self):
     oil_obj = ImportedRecord()
     assert oil_obj is not None
     assert oil_obj.id is None
     with raises(IntegrityError):
         self.session.add(oil_obj)
         self.session.flush()
Exemplo n.º 2
0
    def test_oils_that_share_a_synonym(self):
        oil_args = OilTestCase.get_mock_oil_file_record()
        oil_obj1 = ImportedRecord(**oil_args)
        oil_args.update({u'oil_name': u'Test Oil 2',
                        u'adios_oil_id': u'AD99998'})
        oil_obj2 = ImportedRecord(**oil_args)
        synonym_obj = Synonym('test oil')

        oil_obj1.synonyms.append(synonym_obj)
        oil_obj2.synonyms.append(synonym_obj)

        self.add_objs_and_assert_ids([oil_obj1, oil_obj2, synonym_obj])

        assert oil_obj1.synonyms == [synonym_obj]
        assert oil_obj2.synonyms == [synonym_obj]
        assert synonym_obj.imported == [oil_obj1, oil_obj2]
Exemplo n.º 3
0
    def test_add_cut_to_oil(self):
        oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record())
        cut_obj = Cut(**CutTestCase.get_mock_cut_file_record())

        oil_obj.cuts.append(cut_obj)

        self.add_objs_and_assert_ids([oil_obj, cut_obj])
        assert oil_obj.cuts == [cut_obj]
        assert cut_obj.imported == oil_obj
Exemplo n.º 4
0
    def test_add_dvis_to_oil(self):
        oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record())
        dvis_obj = DVis(**DVisTestCase.get_mock_dvis_file_record())

        oil_obj.dvis.append(dvis_obj)

        self.add_objs_and_assert_ids([oil_obj, dvis_obj])
        assert oil_obj.dvis == [dvis_obj]
        assert dvis_obj.imported == oil_obj
Exemplo n.º 5
0
    def test_add_kvis_to_oil(self):
        oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record())
        kvis_obj = KVis(**KVisTestCase.get_mock_kvis_file_record())

        oil_obj.kvis.append(kvis_obj)

        self.add_objs_and_assert_ids([oil_obj, kvis_obj])
        assert oil_obj.kvis == [kvis_obj]
        assert kvis_obj.imported == oil_obj
Exemplo n.º 6
0
    def test_add_synonym_to_oil(self):
        oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record())
        synonym_obj = Synonym('test oil')

        oil_obj.synonyms.append(synonym_obj)

        self.add_objs_and_assert_ids([oil_obj, synonym_obj])
        assert oil_obj.synonyms == [synonym_obj]
        assert synonym_obj.imported == [oil_obj]
Exemplo n.º 7
0
    def test_add_toxicity_to_oil(self):
        oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record())
        toxicity_obj = \
            Toxicity(**ToxicityTestCase.get_mock_toxicity_file_record())

        oil_obj.toxicities.append(toxicity_obj)

        self.add_objs_and_assert_ids([oil_obj, toxicity_obj])
        assert oil_obj.toxicities == [toxicity_obj]
        assert toxicity_obj.imported == oil_obj
Exemplo n.º 8
0
    def test_add_density_to_oil(self):
        oil_obj = ImportedRecord(**OilTestCase.get_mock_oil_file_record())
        density_obj = \
            Density(**DensityTestCase.get_mock_density_file_record())

        oil_obj.densities.append(density_obj)

        self.add_objs_and_assert_ids([oil_obj, density_obj])
        assert oil_obj.densities == [density_obj]
        assert density_obj.imported == oil_obj
Exemplo n.º 9
0
def add_oil_object(session, file_columns, row_data):
    file_columns = [slugify_filename(c).lower() for c in file_columns]
    row_dict = dict(zip(file_columns, row_data))

    fix_name(row_dict)
    fix_pour_point(row_dict)
    fix_flash_point(row_dict)
    fix_preferred_oils(row_dict)

    oil = ImportedRecord(**row_dict)

    add_synonyms(session, oil, row_dict)
    add_densities(oil, row_dict)
    add_kinematic_viscosities(oil, row_dict)
    add_dynamic_viscosities(oil, row_dict)
    add_distillation_cuts(oil, row_dict)
    add_toxicity_effective_concentrations(oil, row_dict)
    add_toxicity_lethal_concentrations(oil, row_dict)

    session.add(oil)
    transaction.commit()
Exemplo n.º 10
0
 def test_init_with_args(self):
     oil_obj = ImportedRecord(**self.get_mock_oil_file_record())
     self.assert_mock_oil_object(oil_obj)
     self.add_objs_and_assert_ids(oil_obj)