コード例 #1
0
ファイル: bandwidth_file.py プロジェクト: zmchu/stem
    def test_version_position(self):
        """
    Our 'version' header must be in the second position if validated, but
    otherwise doesn't matter.
    """

        desc = BandwidthFile.from_str(WRONG_VERSION_POSITION)
        self.assertEqual('1.1.0', desc.version)

        self.assertRaisesWith(
            ValueError,
            "The 'version' header must be in the second position",
            BandwidthFile.from_str,
            WRONG_VERSION_POSITION,
            validate=True)

        content = BandwidthFile.content(
            collections.OrderedDict([
                ('timestamp', '1410723598'),
                ('file_created', '2019-01-14T05:35:06'),
                ('version', '1.1.0'),
                ('content', []),
            ]))

        self.assertEqual(RIGHT_VERSION_POSITION, content)
コード例 #2
0
ファイル: bandwidth_file.py プロジェクト: xujinjin1/stem
  def test_content_example(self):
    """
    Exercise the example in our content method's pydoc.
    """

    content = BandwidthFile.content(collections.OrderedDict([
      ('timestamp', '12345'),
      ('version', '1.2.0'),
      ('content', []),
    ]))

    self.assertEqual(b'12345\nversion=1.2.0\n=====', content)