Beispiel #1
0
  def testCreate(self):
    importer = pymtgx.Importer(input_file='test/importer/data.csv', 
      format_spec_file='test/importer/indexed.format', 
      output_file='test/importer/output', 
      entity_files=['test/test_entities.mtz'],
      delimiter=',', quotechar='"', skip_lines=1,
      map_header=False)

    importer.create()
Beispiel #2
0
  def testParseLine(self):
    importer = pymtgx.Importer(input_file='test/importer/data.csv', 
      format_spec_file='test/importer/indexed.format', 
      output_file='test/importer/output', 
      entity_files=['test/test_entities.mtz'],
      delimiter=',', quotechar='"', skip_lines=1,
      map_header=False)
    
    row = ['X', 'Y', 'Z']

    self.assertEqual(3, importer._parse_line(row))
Beispiel #3
0
  def testParseLineWithEmptyValue(self):
    importer = pymtgx.Importer(input_file='test/importer/data_with_empty.csv', 
      format_spec_file='test/importer/indexed.format', 
      output_file='test/importer/output', 
      entity_files=['test/test_entities.mtz'],
      delimiter=',', quotechar='"', skip_lines=1,
      map_header=False)    

    # Line 1: col 0 -> col 2
    # Line 2: col 0 -> col 1
    # The remaining four candidates contain at least one empty value
    self.assertEqual(2, importer.number_of_edges)
Beispiel #4
0
  def testReadMappedformat_spec(self):
    importer = pymtgx.Importer(input_file='test/importer/data.csv', 
      format_spec_file='test/importer/mapped.format', 
      output_file='test/importer/output', 
      entity_files=['test/test_entities.mtz'],
      delimiter=',', quotechar='"', skip_lines=0,
      map_header=True)

    self.assertEqual(3, len(importer.format_spec))

    self.assertEqual(0, importer.format_spec[0]['from_index'])
    self.assertEqual('Person', importer.format_spec[0]['from_type'])
    self.assertEqual(2, importer.format_spec[0]['to_index'])
    self.assertEqual('EmailAddress', importer.format_spec[0]['to_type'])
    self.assertEqual('Edge label 1', importer.format_spec[0]['edge_label'])

    self.assertEqual(2, importer.format_spec[2]['from_index'])
    self.assertEqual('EmailAddress', importer.format_spec[2]['from_type'])
    self.assertEqual(1, importer.format_spec[2]['to_index'])
    self.assertEqual('Person', importer.format_spec[2]['to_type'])
    self.assertEqual('Edge label 3', importer.format_spec[2]['edge_label'])