コード例 #1
0
  def test_pin_with_custom_metadata(self):
    name = "iris-metadata"
    source = "The R programming language"

    pins.pin(iris,
      name = name,
      board = self.board,
      metadata = {
        "source": source,
        "columns": [
          { "name": "Species", "description": "Really like this column" },
          { "name": "Sepal.Length", "description": "Sepal Length" },
          { "name": "Sepal.Width", "description": "Sepal Width" },
          { "name": "Petal.Length", "description": "Petal Length" },
          { "name": "Petal.Width", "description": "Petal Width" },
        ]
      }
    )

    info = pins.pin_info(name, board = self.board, metadata = True)

    assert name in info["name"]
    assert info["source"] == source
    assert len(info["columns"]) == 5
    assert info["columns"][0]["name"] == "Species"

    pins.pin_remove(name, self.board)
コード例 #2
0
  def test_pin_version(self):
    va = [1, 2, 3]
    vb = [11, 12, 13]

    pins.pin(va, name = self.pin_version_name, board = self.board)
    pins.pin(vb, name = self.pin_version_name, board = self.board)

    versions = pins.pin_versions(self.pin_version_name, board = self.board)

    assert len(versions["version"]) == 2

    pin1 = pins.pin_get(self.pin_version_name, board = self.board, version = versions["version"][0])
    pin2 = pins.pin_get(self.pin_version_name, board = self.board, version = versions["version"][1])

    assert pin1 == vb
    assert pin2 == va
コード例 #3
0
  def test_pin_dataframe(self):
    cached_data = pins.pin(
      iris,
      name = self.dataset_name,
      board = self.board
    )

    for idx, x in enumerate(cached_data):
      assert sorted(x.items()) == sorted(iris[idx].items())
コード例 #4
0
ファイル: test.py プロジェクト: stefanfritsch/pins
def test_pin():
  data = {
    'apples':  [1, 2, 0, 2], 
    'bananas': [0, 1, 2, 2]
  }
  
  data = pd.DataFrame(data)
  data = pins.pin(data, "fruits")
  
  assert len(data) == 4
コード例 #5
0
  def test_pin_file(self):
    cached_path = pins.pin(
      self.text_file_path,
      name = self.pin_name,
      board = self.board
    )
    cached_data = self.read_lines(cached_path)

    assert len(cached_path) > 0
    assert len(cached_data) == 1
    assert cached_data[0] == "hello world"
コード例 #6
0
def test_can_pin_file(board):
    config = configuration_test(board)

    if (board == "s3"):
        return  # NYI

    assert os.path.isfile(config["text_file_path"])

    cached_path = pins.pin(config["text_file_path"],
                           name=pin_name,
                           board=board)

    assert len(cached_path) > 0

    in_file = open(config["text_file_path"], "r")
    lines = in_file.readlines()
    in_file.close()

    assert lines == ['hello world']