コード例 #1
0
    def testSetTexture(self):
        """Running set_texture should set a texture."""
        self.assertEqual(self.material.texture.__class__,
                         pywavefront.texture.Texture)
        self.assertEqual(self.material.texture_ambient.__class__,
                         pywavefront.texture.Texture)

        self.assertEqual(self.material.texture.path, str(fixture('4x4.png')))
        self.assertEqual(self.material.texture_ambient.path, str(fixture('4x4.png')))
コード例 #2
0
    def testSetTexture(self):
        """Running set_texture should set a texture."""
        self.assertEqual(self.material.texture.__class__,
                         pywavefront.texture.Texture)
        self.assertEqual(self.material.texture_ambient.__class__,
                         pywavefront.texture.Texture)

        self.assertEqual(self.material.texture.path, fixture('4x4.png'))
        self.assertEqual(self.material.texture_ambient.path, fixture('4x4.png'))
コード例 #3
0
ファイル: test_parser.py プロジェクト: mmaartijn/PyWavefront
    def testOnlyOneVertex(self):
        meshes = pywavefront.Wavefront(fixture('simple_one_vertex.obj'))
        self.vertices = meshes.vertices
        self.meshes = meshes.mesh_list

        self.assertEqual(1, len(self.meshes))
        self.assertEqual(1, len(self.vertices))
コード例 #4
0
    def register_forecast_http_call(self):
        url = "https://api.forecast.io/forecast/%s/%s,%s"\
              "?units=si&exclude=currently,minutely,daily&extend=hourly" % (
                  FORECASTIO_API_KEY, LATITUDE, LONGITUDE)

        httpretty.register_uri(httpretty.GET, url,
                               body=fixture('forecast.json'))
コード例 #5
0
    def register_forecast_http_call(self):
        url = "https://api.forecast.io/forecast/%s/%s,%s"\
              "?units=si&exclude=currently,minutely,daily&extend=hourly" % (
                  FORECASTIO_API_KEY, LATITUDE, LONGITUDE)

        httpretty.register_uri(httpretty.GET, url,
                               body=fixture('forecast.json'))
コード例 #6
0
    def test_builds_object_from_forecast_response(self):
        forecast_response = json.loads(fixture('forecast_response.json'))

        weather = forecast.Weather(forecast_response)

        self.assertEqual(weather.text_summary, forecast_response['summary'])
        self.assertEqual(weather.temperature, forecast_response['temperature'])
        self.assertEqual(weather.cloud_cover, forecast_response['cloudCover'])
コード例 #7
0
    def test_builds_object_from_forecast_response(self):
        forecast_response = json.loads(fixture('forecast_response.json'))

        weather = forecast.Weather(forecast_response)

        self.assertEqual(weather.text_summary, forecast_response['summary'])
        self.assertEqual(weather.temperature, forecast_response['temperature'])
        self.assertEqual(weather.cloud_cover, forecast_response['cloudCover'])
コード例 #8
0
    def register_spacetrack_http_call(self):
        httpretty.register_uri(httpretty.POST,
                               'https://www.space-track.org/ajaxauth/login',
                               body="")

        url = 'https://www.space-track.org/basicspacedata/query/class/' \
              'tle_latest/NORAD_CAT_ID/25544/ORDINAL/1/'
        httpretty.register_uri(httpretty.GET, url,
                               body=fixture('spacetrack_tle.json'))
コード例 #9
0
 def testPathedImageName(self):
     """For Texture objects, the image name should be the last component of the path."""
     texture = pywavefront.texture.Texture('4x4.png',
                                           search_path=utils.FIXTURE_PATH)
     self.assertEqual(texture.path, str(utils.fixture('4x4.png')))
     self.assertEqual(texture.name, '4x4.png')
     self.assertTrue(texture)
     self.assertEqual(texture.image_name, '4x4.png')
     self.assertEqual(texture.file_name, '4x4.png')
     self.assertTrue(os.path.exists(texture.find()))
コード例 #10
0
    def test_genesis_block(self):
        blocks = Dru.get('/api/get_blocks/0/0')
        test_block = fixture('zcash_genesis_block.json')

        for b in blocks + [test_block]:
            # this value changes!
            b['_id'] = None
            b['confirmations'] = None
            b['valuePools'] = None

        self.assertEqual(blocks[0], test_block)
コード例 #11
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def testTextures(self):
     self.assertEqual(self.material1.texture.path, fixture('kd.png'))
     self.assertEqual(self.material1.texture_ambient.path, fixture('ka.png'))
     self.assertEqual(self.material1.texture_specular_color.path, fixture('ks.png'))
     self.assertEqual(self.material1.texture_specular_highlight.path, fixture('ns.png'))
     self.assertEqual(self.material1.texture_alpha.path, fixture('d.png'))
     self.assertEqual(self.material1.texture_bump.path, fixture('bump.png'))
コード例 #12
0
    def testObjOnlyPositions(self):
        meshes = pywavefront.Wavefront(fixture('simple_positions.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(
            self.mesh1.materials[0].vertices,
            [0.04, 0.05, 0.06, 0.01, 0.02, 0.03, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices,
                         [-1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "V3F")
コード例 #13
0
 def testTextures(self):
     self.assertEqual(self.material1.texture.path, fixture('kd.png'))
     self.assertEqual(self.material1.texture_ambient.path,
                      fixture('ka.png'))
     self.assertEqual(self.material1.texture_specular_color.path,
                      fixture('ks.png'))
     self.assertEqual(self.material1.texture_specular_highlight.path,
                      fixture('ns.png'))
     self.assertEqual(self.material1.texture_alpha.path, fixture('d.png'))
     self.assertEqual(self.material1.texture_bump.path, fixture('bump.png'))
コード例 #14
0
    def test_iss_tle_data(self):
        httpretty.register_uri(httpretty.POST,
                               'https://www.space-track.org/ajaxauth/login',
                               body="")

        url = 'https://www.space-track.org/basicspacedata/query/class/' \
              'tle_latest/NORAD_CAT_ID/25544/ORDINAL/1/'
        httpretty.register_uri(httpretty.GET, url,
                               body=fixture('spacetrack_tle.json'))

        username = os.getenv('SPACETRACK_USERNAME', '')
        password = os.getenv('SPACETRACK_PASSWORD', '')

        tle_getter = tle_data.TLE_getter(username, password)
        iss_tle_data = tle_getter.get_data("25544")
        self.assertEqual(iss_tle_data.tle_line0, "ISS (ZARYA)")
コード例 #15
0
    def testObjColors(self):
        meshes = pywavefront.Wavefront(fixture('simple_colors.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            14.0, 15.0, 1.0, 0.0, 0.0, 20.0, 21.0, 22.0, 0.04, 0.05, 0.06,
            12.0, 13.0, 1.0, 0.0, 0.0, 20.0, 21.0, 22.0, 0.01, 0.02, 0.03,
            10.0, 11.0, 1.0, 0.0, 0.0, 20.0, 21.0, 22.0, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, -0.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "T2F_C3F_N3F_V3F")
コード例 #16
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
    def testObjOnlyPositions(self):
        meshes = pywavefront.Wavefront(fixture('simple_positions.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            0.04, 0.05, 0.06,
            0.01, 0.02, 0.03,
            0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            -1.0, 0.0, 1.0,
            1.0, 0.0, 1.0,
            1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "V3F")
コード例 #17
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
    def testObjColors(self):
        meshes = pywavefront.Wavefront(fixture('simple_colors.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            14.0, 15.0, 1.0, 0.0, 0.0, 20.0, 21.0, 22.0, 0.04, 0.05, 0.06,
            12.0, 13.0, 1.0, 0.0, 0.0, 20.0, 21.0, 22.0, 0.01, 0.02, 0.03,
            10.0, 11.0, 1.0, 0.0, 0.0, 20.0, 21.0, 22.0, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, -0.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "T2F_C3F_N3F_V3F")
コード例 #18
0
    def test_iss_tle_data(self):
        httpretty.register_uri(httpretty.POST,
                               'https://www.space-track.org/ajaxauth/login',
                               body="")

        url = 'https://www.space-track.org/basicspacedata/query/class/' \
              'tle_latest/NORAD_CAT_ID/25544/ORDINAL/1/'
        httpretty.register_uri(httpretty.GET,
                               url,
                               body=fixture('spacetrack_tle.json'))

        username = os.getenv('SPACETRACK_USERNAME', '')
        password = os.getenv('SPACETRACK_PASSWORD', '')

        tle_getter = tle_data.TLE_getter(username, password)
        iss_tle_data = tle_getter.get_data("25544")
        self.assertEqual(iss_tle_data.tle_line0, "ISS (ZARYA)")
コード例 #19
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
    def testObjNoUVs(self):
        """Parse object with no uvs"""
        meshes = pywavefront.Wavefront(fixture('simple_normals.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            20.0, 21.0, 22.0, 0.04, 0.05, 0.06,
            20.0, 21.0, 22.0, 0.01, 0.02, 0.03,
            20.0, 21.0, 22.0, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, -0.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "N3F_V3F")
コード例 #20
0
    def testObjNoUVs(self):
        """Parse object with no uvs"""
        meshes = pywavefront.Wavefront(fixture('simple_normals.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            20.0, 21.0, 22.0, 0.04, 0.05, 0.06,
            20.0, 21.0, 22.0, 0.01, 0.02, 0.03,
            20.0, 21.0, 22.0, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, -0.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "N3F_V3F")
コード例 #21
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
    def testObjNoNormals(self):
        """Parse obj without normals"""
        # tests v, vt and f
        meshes = pywavefront.Wavefront(fixture('simple_vt.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            14.0, 15.0, 0.04, 0.05, 0.06,
            12.0, 13.0, 0.01, 0.02, 0.03,
            10.0, 11.0, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            1.0, 0.0, -1.0, 0.0, 1.0,
            0.0, 0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "T2F_V3F")
コード例 #22
0
    def testObjNoNormals(self):
        """Parse obj without normals"""
        # tests v, vt and f
        meshes = pywavefront.Wavefront(fixture('simple_vt.obj'))
        self.mesh1 = meshes.mesh_list[0]
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh1.materials[0].vertices, [
            14.0, 15.0, 0.04, 0.05, 0.06,
            12.0, 13.0, 0.01, 0.02, 0.03,
            10.0, 11.0, 0.07, 0.08, 0.09])

        self.assertEqual(self.mesh2.materials[0].vertices, [
            1.0, 0.0, -1.0, 0.0, 1.0,
            0.0, 0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, 1.0, 0.0, -1.0])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "T2F_V3F")
コード例 #23
0
    def test_undefined_uvs(self):
        """obj file were some uv entries are undefiend"""
        meshes = pywavefront.Wavefront(fixture('simple_missing_uv.obj'))
        self.mesh2 = meshes.mesh_list[1]

        self.assertEqual(self.mesh2.materials[0].vertices, [
            1.0, 0.0, 0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            0.0, 0.0, 0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, 0.0, 1.0, -0.0, 1.0, 0.0, -1.0,

            10.0, 11.0, 0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            10.0, 11.0, 0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            10.0, 11.0, 0.0, 1.0, -0.0, 1.0, 0.0, -1.0,

            1.0, 0.0, 0.0, 1.0, -0.0, -1.0, 0.0, 1.0,
            0.0, 0.0, 0.0, 1.0, -0.0, 1.0, 0.0, 1.0,
            0.0, 1.0, 0.0, 1.0, -0.0, 1.0, 0.0, -1.0,
        ])

        self.assertEqual(self.mesh2.materials[0].vertex_format, "T2F_N3F_V3F")
コード例 #24
0
class CacheTestNoMaterials(CacheTest):
    obj_file = fixture('simple_no_mtl.obj')
コード例 #25
0
 def setUp(self):
     self.mesh_names = ['Simple', 'SimpleB']
     self.material_names = ['Material.simple', 'Material2.simple']
     self.meshes = pywavefront.Wavefront(fixture('simple.obj'))
コード例 #26
0
 def setUp(self):
     # reset the obj file to new file with no mtl line
     self.mesh_names = ['Simple', 'SimpleB']
     self.material_names = ['Material.simple', 'Material2.simple']
     self.meshes = pywavefront.Wavefront(fixture('simple_extra_empty_lines.obj'))
コード例 #27
0
class CacheTestUnknownMtl(CacheTest):
    obj_file = fixture('simple_unknown_usemtl.obj')
    create_materials = True
コード例 #28
0
 def test_missing_material_error(self):
     """Parser should crash if `create_materials` is not set"""
     with self.assertRaises(IOError):
         pywavefront.Wavefront(fixture('simple_missing_material.obj'))
コード例 #29
0
 def setUp(self):
     # Append current path to locate files
     self.material = pywavefront.material.Material(fixture('material'))
     self.material.set_texture(fixture('4x4.png'))
     self.material.set_texture_ambient(fixture('4x4.png'))
コード例 #30
0
ファイル: test_degree_max_api.py プロジェクト: guyiths/Dru
    def test_degree_max_all(self):
        block = Dru.get('/api/get_degree_max/0/99/all')
        test_block = fixture('zcash_degree_max_all.json')

        self.assertEqual(block, test_block)
コード例 #31
0
 def setUp(self):
     self.meshes = pywavefront.Wavefront(fixture('arbitrary-faces.obj'), collect_faces=True).meshes
コード例 #32
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def test_missing_material_error(self):
     """Parser should crash if `create_materials` is not set"""
     with self.assertRaises(IOError):
         pywavefront.Wavefront(fixture('simple_missing_material.obj'))
コード例 #33
0
 def testPathedImageName(self):
     """For Texture objects, the image name should be the last component of the path."""
     my_texture = pywavefront.texture.Texture(fixture('4x4.png'))
     self.assertEqual(my_texture.path, fixture('4x4.png'))
コード例 #34
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def test_missing_material_create(self):
     """Parser should handle missing materials if `create_materials` is set"""
     pywavefront.Wavefront(fixture('simple_missing_material.obj'), create_materials=True)
コード例 #35
0
 def testUnknownUsemtl(self):
     """Referencing an unknown material with usemtl should raise an exception."""
     self.assertRaises(pywavefront.PywavefrontException,
                       pywavefront.Wavefront,
                       fixture('simple_unknown_usemtl.obj'))
コード例 #36
0
 def setUp(self):
     # reset the obj file to new file with no mtl line
     self.mesh_names = [None]
     self.material_names = ["default0"]
     self.meshes = pywavefront.Wavefront(fixture('simple_no_object_no_mtl.obj'))
コード例 #37
0
 def testMissingParseFunction(self):
     """Attempting to parse with a missing parse function should raise an exception."""
     # since no parse functions have been defined, this will always fail in strict mode
     parser = pywavefront.parser.Parser(fixture('simple.obj'), strict=True)
     self.assertRaises(PywavefrontException, parser.parse)
コード例 #38
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def setUp(self):
     # Append current path to locate files
     meshes = pywavefront.Wavefront(fixture('simple.obj.gz'))
     self.mesh1 = meshes.mesh_list[0]
     self.mesh2 = meshes.mesh_list[1]
コード例 #39
0
 def testMissingParsedFile(self):
     """Attempting to read a non-exiting file should raise an exception."""
     file_name = 'doesnotexist.obj'
     parser = pywavefront.parser.Parser(fixture(file_name))
     self.assertRaises(IOError, parser.parse)
コード例 #40
0
 def test_missing_material_create(self):
     """Parser should handle missing materials if `create_materials` is set"""
     pywavefront.Wavefront(fixture('simple_missing_material.obj'), create_materials=True)
コード例 #41
0
 def setUp(self):
     # Append current path to locate files
     meshes = pywavefront.Wavefront(fixture('simple.obj.gz'))
     self.mesh1 = meshes.mesh_list[0]
     self.mesh2 = meshes.mesh_list[1]
コード例 #42
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def setUp(self):
     parser = MaterialParser(fixture('simple_parsetest.mtl'))
     self.materials = parser.materials
     self.material1 = self.materials['Material.simple']
     self.material2 = self.materials['Material2.simple']
コード例 #43
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def testMissingParseFunction(self):
     """Attempting to parse with a missing parse function should raise an exception."""
     # since no parse functions have been defined, this will always fail in strict mode
     parser = pywavefront.parser.Parser(fixture('simple.obj'), strict=True)
     self.assertRaises(PywavefrontException, parser.parse)
コード例 #44
0
class CacheTestNegativeIndices(CacheTest):
    obj_file = fixture('simple_negative_indices.obj')
コード例 #45
0
ファイル: test_texture.py プロジェクト: greenmoss/PyWavefront
 def testPathedImageName(self):
     """For Texture objects, the image name should be the last component of the path."""
     my_texture = pywavefront.texture.Texture(fixture('4x4.png'))
     self.assertEqual(my_texture.path, fixture('4x4.png'))
コード例 #46
0
 def setUp(self):
     # reset the obj file to new file with no mtl line
     self.mesh_names = ['Simple', 'SimpleB']
     self.material_names = ['Material.simple', 'Material2.simple']
     self.meshes = pywavefront.Wavefront(
         fixture('simple_extra_empty_lines.obj'))
コード例 #47
0
 def setUp(self):
     # Append current path to locate files
     self.material = pywavefront.material.Material(fixture('material'))
     self.material.set_texture(str(fixture('4x4.png')), '')
     self.material.set_texture_ambient(str(fixture('4x4.png')), '')
コード例 #48
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def setUp(self):
     self.meshes = pywavefront.Wavefront(fixture('arbitrary-faces.obj'), collect_faces=True).meshes
コード例 #49
0
class CacheTestNoObjNoMtl(CacheTest):
    obj_file = fixture('simple_no_object_no_mtl.obj')
コード例 #50
0
ファイル: test_parser.py プロジェクト: greenmoss/PyWavefront
 def testMissingParsedFile(self):
     """Attempting to read a non-exiting file should raise an exception."""
     file_name = 'doesnotexist.obj'
     parser = pywavefront.parser.Parser(fixture(file_name))
     self.assertRaises(IOError, parser.parse)
コード例 #51
0
class CacheTest(unittest.TestCase):
    """Create and load cache for a specific obj file"""
    maxDiff = None
    obj_file = fixture('simple.obj')
    create_materials = False

    def load_obj(self, filename, fake_io=None):
        """Helper method loading files with proper mocks"""
        if not fake_io:
            self.fake_io = FakeIO()

        if not fake_io:
            scene = Wavefront(filename, cache=True, create_materials=self.create_materials)

        with mock.patch("pywavefront.cache.gzip.open", new=self.fake_io):
            with mock.patch("pywavefront.cache.open", new=self.fake_io):
                with mock.patch("pywavefront.cache.os.path.exists", new=self.fake_io.exisis):
                    if fake_io:
                        scene = Wavefront(filename, cache=True, create_materials=self.create_materials)
                    scene.parser.post_parse()

        self.meta_file = self.obj_file.with_suffix(self.obj_file.suffix + '.json')
        self.cache_file = self.obj_file.with_suffix(self.obj_file.suffix + '.bin')
        return scene

    @property
    def meta(self):
        return self.fake_io[self.meta_file].json()

    @property
    def cache(self):
        return self.fake_io[self.cache_file]

    def test_create(self):
        scene = self.load_obj(self.obj_file)

        # Sanity check cache data
        self.assertTrue(self.meta.get('version'), msg="Missing version info in meta file: {}".format(self.meta))
        self.assertEqual(self.meta['mtllibs'], scene.mtllibs)
        self.assertEqual(self.cache.size, sum(len(m.vertices) for m in scene.materials.values()) * 4)

    def test_load(self):
        # Load the file creating a cache
        scene_pre = self.load_obj(self.obj_file)
        # Load again using cache
        scene_post = self.load_obj(self.obj_file, self.fake_io)

        self.assertFalse(scene_pre.parser.cache_loaded, msg="File was loaded from cache")
        self.assertTrue(scene_post.parser.cache_loaded, msg="File was not loaded from cache")

        # Compare pre and post cache
        self.assertEqual(sorted(scene_pre.materials.keys()), sorted(scene_post.materials.keys()))
        for name, pre_mat in scene_pre.materials.items():
            post_mat = scene_post.materials[name]
            self.assertNotEqual(pre_mat, post_mat)  # Ensure they are differnt objects!
            self.assertEqual(len(pre_mat.vertices), len(post_mat.vertices))
            for a, b in zip(pre_mat.vertices, post_mat.vertices):
                self.assertAlmostEqual(a, b, msg="{} != {}".format(pre_mat.vertices, post_mat.vertices))
            self.assertEqual(pre_mat.vertex_format, post_mat.vertex_format)
            self.assertEqual(pre_mat.name, post_mat.name)

    def test_missing_meta(self):
        # Load the file creating a cache
        scene_pre = self.load_obj(self.obj_file)

        # Be naughty deleting the meta file
        del self.fake_io[self.meta_file]

        # Load again using cache
        scene_post = self.load_obj(self.obj_file, self.fake_io)
        # No cache loader should be created
        self.assertFalse(scene_pre.parser.cache_loaded)
        self.assertFalse(scene_post.parser.cache_loaded)
コード例 #52
0
 def setUp(self):
     parser = MaterialParser(fixture('simple_parsetest.mtl'))
     self.materials = parser.materials
     self.material1 = self.materials['Material.simple']
     self.material2 = self.materials['Material2.simple']
コード例 #53
0
class CacheTestSimpleColors(CacheTest):
    obj_file = fixture('simple_colors.obj')
コード例 #54
0
    def test_generates_cloud_summary(self):
        forecast_response = json.loads(fixture('forecast_response.json'))

        weather = forecast.Weather(forecast_response)

        self.assertEqual(weather.cloud_summary, 'cloudy with breaks')