old_contents: # import os
  # import unittest
  # from magpie.linear_classifier.config import MODEL_PATH
  # from magpie.linear_classifier import api
  # from magpie.linear_classifier.utils import calculate_recall_for_kw_candidates
  #
  #
  # def train_model_if_necessary(model_path):
  #     """ If the model under a given path does not exist, create one. """
  #     if not os.path.exists(model_path):
  #         api.train(model_path=model_path, word2vec_path=None, verbose=False)
  #
  #
  # class TestAPI(unittest.TestCase):
  #     """ Basic tests for making sure that the API works """
  #     def test_train(self):
  #         api.train(verbose=False, word2vec_path=None)
  #
  #     def test_test(self):
  #         train_model_if_necessary(MODEL_PATH)
  #         metrics = api.test(verbose=False)
  #         self.assertGreater(metrics['map'], 0)
  #         self.assertGreater(metrics['mrr'], 0)
  #         self.assertGreater(metrics['ndcg'], 0)
  #         self.assertGreater(metrics['p_at_3'], 0)
  #         self.assertGreater(metrics['p_at_5'], 0)
  #
  #     def test_candidate_recall(self):
  #         recall = calculate_recall_for_kw_candidates(verbose=False)
  #         self.assertGreater(recall, 0)
  
new_contents: import io
  import os
  import unittest
  
  # This one is hacky, but I'm too lazy to do it properly!
  PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
  
  DATA_DIR = os.path.join(PROJECT_DIR, 'data', 'hep-categories')
  TRAIN_DIR = os.path.join(DATA_DIR, 'train')
  TEST_DIR = os.path.join(DATA_DIR, 'test')
  
  class TestAPI(unittest.TestCase):
  	""" Basic integration test """
  	def test_integrity(self):
  		# Get them labels!
  		label_file = os.path.join(PROJECT_DIR, 'data', 'hep-categories.labels')
  		with io.open(label_file, 'r') as f:
  			labels = {line.rstrip('\n') for line in f}
  
  		# Run the model
  		from magpie import MagpieModel
  		model = MagpieModel()
  		model.init_word_vectors(TRAIN_DIR, vec_dim=100)
  		history = model.train(TRAIN_DIR, labels, test_dir=TEST_DIR, nb_epochs=3)
  		assert history is not None
  
  		# Do a simple prediction
  		predictions = model.predict_from_text("Black holes are cool!")
  		assert len(predictions) == len(labels)
  
  		# Assert the hell out of it!
  		for lab, val in predictions:
  			assert lab in labels
  			assert 0 <= val <= 1
  
subject: add a simple integration test